package com.example.moblie2021606143cwj0408;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity6 extends AppCompatActivity {

    private TextView tvMainTitle6;
    private TextView tvMain8;
    private TextView tvMain9;
    private TextView textView5;
    private TextView tvMain10;
    private EditText edt5;
    private Button btn4;
    private TextView tv_main_result5;
    int x,y;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main6);
        initView();
        btn4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String string =edt5.getText().toString();
                int x =Integer.valueOf(string).intValue();
                if (x < 1) {
                    y = x;
                    tv_main_result5.setText(y);
                } else if (1 <= x && x < 10) {
                    y = 2 * x - 1;
                    String str1 = String.format("%.2f", y);
                   tv_main_result5.setText(str1);
                } else if (x >= 10) {
                    y = 3 * x - 11;
                    String str2 = String.format("%.2f", y);
                    tv_main_result5.setText(str2);
                }
            }
        });
    }

    private void initView() {
        tvMainTitle6 = findViewById(R.id.tv_main_title6);
        tvMain8 = findViewById(R.id.tv_main8);
        tvMain9 = findViewById(R.id.tv_main9);
        textView5 = findViewById(R.id.textView5);
        tvMain10 = findViewById(R.id.tv_main10);
        edt5 = findViewById(R.id.edt5);
        btn4 = findViewById(R.id.btn4);
        tv_main_result5 = findViewById(R.id.tv_main_result5);
    }
}